#include <QApplication>
#include <QProcess>
#include <iostream>
#include <QJsonDocument>
#include <QThread>


//#include "adb_operation.h"
#include "AnGlobal.h"
#include "AnAdbServer.h"
#include "AnCallback.h"

#include "ui_mainwin.h"
#include "ui_mainpage.h"
#include "ui_apppage.h"
#include "ui_filepage.h"
#include "ui_contactpage.h"

#include "AnMainwin.h"
#include "AnAdbchoseDialog.h"


class mCallBack : public AnCallback
{
public:
	void response(QJsonObject an_response)
	{
		std::cout << "response: \n" << QJsonDocument(an_response).toJson().data() << std::endl;
	}
};


int main(int argc, char *argv[])
{

    app = new QApplication(argc, argv);

    //初始化
    AnGlobal::globalInit();

/*
    current_devices_id = "34087a82";


    QJsonObject resq;
    QJsonObject resq_data;
    resq.insert(NAME, QJsonValue("file_export"));
    resq.insert(STATUS, QJsonValue(REQUEST));
    //resq_data.insert("id", QJsonValue("34087a82"));
    resq_data.insert("local_path", QJsonValue("/tmp/a d.c"));
    resq_data.insert("remote_path", QJsonValue("/sdcard/a b.c"));
    resq.insert(DATA, QJsonValue(resq_data));

    mCallBack mcallback;
    adb_server->adbServerManager(resq, (AnCallback *)&mcallback);
*/

    /*

	QJsonObject j_connect_build;
	QJsonObject j_connect_build_data;
	j_connect_build.insert(NAME, QJsonValue("connect_build"));
	j_connect_build.insert(STATUS, QJsonValue(REQUEST));
	j_connect_build_data.insert("id", QJsonValue("34087a82"));
	j_connect_build.insert(DATA, QJsonValue(j_connect_build_data));

	QJsonObject j_connect_check;
	QJsonObject j_connect_check_data;
	j_connect_check.insert(NAME, QJsonValue("app_uninstall"));
	j_connect_check.insert(STATUS, QJsonValue(REQUEST));
	j_connect_check_data.insert("id", QJsonValue("34087a82"));
	j_connect_check_data.insert("package_name", "com.koushikdutta.backup");
	j_connect_check.insert(DATA, QJsonValue(j_connect_check_data));



	mCallBack mcallback;
	adb_server->adbServerManager(j_connect_build, (AnCallback *)&mcallback);
	adb_server->adbServerManager(j_connect_check, (AnCallback *)&mcallback);

*/
	//QThread::sleep(10);



/*
    Ui::mainwin * mw = new Ui::mainwin();
    Ui::mainpage * mp = new Ui::mainpage();
    Ui::apppage * ap = new Ui::apppage();
    Ui::filepage * fp = new Ui::filepage();
    Ui::contactpage * cp = new Ui::contactpage();
    QWidget widget;
    mw->setupUi(&widget);
    mp->setupUi(mw->tab_mainpage);
    ap->setupUi(mw->tab_app);
    fp->setupUi(mw->tab_file);
    cp->setupUi(mw->tab_contact);
    widget.show();
*/

    //建立程序窗口
    AnMainwin * amw = new AnMainwin();
    amw->show();
    //应用程序启动
    amw->start();


    int exec_status = app->exec();
    //AnGlobal::globalFinal();
    return exec_status;
}
